package com.CampusLife.controller;

import com.CampusLife.bean.LostProduct;
import com.CampusLife.bean.News;
import com.CampusLife.bean.Product;
import com.CampusLife.service.*;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/index")
public class IndexController {
    @Resource
    private IProductService iproductService;
    @Resource
    private ILostProductService iLostProductService;
    @Resource
    private INewsService iNewsService;
    @RequestMapping("/ToIndex")
    public String ToIndex(Model model){
        List<Product> products=iproductService.getOrder();
        List<LostProduct>  lostProducts=iLostProductService.getOrder();
        List<News> news=iNewsService.getOrder();
        model.addAttribute("products",products);
        model.addAttribute("lostProducts",lostProducts);
        model.addAttribute("news",news);
        return "home/home";
    }
}
